"""
主题: 在函数上添加包装器
问题: 你想在函数上添加一个包装器，增加额外的操作处理(比如日志、计时等)。
提示 : 
"""
import time
from functools import wraps

def timethis(func):
    '''
    Decorator that reports the execution time.
    '''
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print(func.__name__, end-start)
        return result
    return wrapper

@timethis
def countdown(n):
    """
    Counts down
    """
    while n > 0:
        n -= 1

def recipe1():
    countdown(100000)
    countdown(10000000)

def main():
    print('recipe1'.center(20, '*'))
    recipe1()


if __name__ == '__main__':
    main()   